home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Online / tablePlug / rx / tvp_dt.tpx < prev    next >
Text File  |  1999-10-11  |  2KB  |  79 lines

  1. /*
  2.  
  3.     tvp_dt.tpx v1.0 © 1999 Esteve Boix
  4.  
  5.     This module uses the tool (included in tablePlug)
  6.     "tp_dtc" to load the image and
  7.     save it in standard IFF24 bit format. This image
  8.     is then loaded into TVPaint, it scales it down
  9.     and saves it as JPEG file.
  10.  
  11.     This way, any image file recognized by datatypes is
  12.     loaded without problems.
  13.     
  14.     Tested only on the freeware version 3.59 of TVPaint.
  15.  
  16.     Args: SIZEX SIZEY JPEG_COMPRESSION
  17.  
  18.     Where:
  19.  
  20.         SIZEX, SIZEY        Size in pixels of the thumbnail
  21.         JPEG_COMPRESSION    Well...
  22.  
  23. */
  24.  
  25. multiview="sys:utilities/multiview"     /* Modify if necessary */
  26.  
  27. options results
  28.  
  29. parse arg maxsizex maxsizey compression infile outfile
  30.  
  31. infile=strip(infile)
  32. outfile=strip(outfile)
  33.  
  34. /* Load the image and save it with tp_dtc */
  35. address command
  36. 'tableplug:tools/tp_dtc >nil: <nil: '||infile||' ram:tP_temp_image.iff'
  37.  
  38. address 'rexx_TVPaint'
  39. 'tv_LoadProject ram:tP_temp_image.iff'
  40. if rc~=0 then exit
  41.  
  42. /* Now delete the iff image created by tp_dtc */
  43. address command
  44. 'delete >nil: <nil: ram:tP_temp_image.iff'
  45. 'delete >nil: <nil: '||outfile   /* Delete a possible old thumbnail.... TVPaint doesn't like it */
  46.  
  47. address 'rexx_TVPaint'
  48.  
  49. /* Obtain info about the image */
  50. tv_getwidth
  51. x = result
  52. tv_getheight
  53. y = result
  54.  
  55. /* ...and calculate the thumbnail resolution */
  56.  
  57. comp=trunc((maxsizex/x)*y)
  58.  
  59. if comp<=maxsizey then do
  60.  
  61.     tv_resizepage maxsizex comp 2   /* Discovered after some attempts... */
  62.     end
  63.  
  64. else do
  65.  
  66.     comp2=trunc((maxsizey/y)*x)
  67.     tv_resizepage comp2 maxsizey 2  /* Discovered after some attempts... */
  68.  
  69. end
  70.  
  71. /* And save the image */
  72. address 'rexx_TVPaint'
  73. tv_savemode jpeg compression
  74. tv_savedisplay outfile
  75.  
  76. address command
  77. 'delete >nil: <nil: '||outfile||'.info'     /* Delete the info file created by TVPaint */
  78.  
  79.